<?php

ob_start();
session_start();
include_once('../php/include_all.php');
$usr = addslashes($_POST['whoareyou']);
$pwd = addslashes($_POST['yoursecret']);

if (isset($_POST['what']))
    $what = $_POST['what'];
if (isset($_GET['what']))
    $what = $_GET['what'];

if ($what == 'inn') {
    $h = get_data("select id_bidang,id_skpd, nama_skpd, userx, passwordx, level from spm_skpd where passwordx='".$pwd."' AND userx='".$usr."'");    
    if (count($h) > 0) {
		$_SESSION['_id'] = $h['id_skpd'];	
        $_SESSION['_skpd'] = $h['nama_skpd'];
        $_SESSION['_username'] = $h['userx'];
        $_SESSION['_level'] = $h['level'];
		$_SESSION['_id_bidang'] = $h['id_bidang'];
		$level = $h['level'];
        if($level == 'admin'){
			echo 'suk___admins/';
		}else{
			echo 'suk___skpd/';
		}
    } else {
        echo 'gal';
    }
}else if ($what == 'outt'){
    unset($_SESSION['_id']);
	unset($_SESSION['_skpd']);
    unset($_SESSION['_username']);
    unset($_SESSION['_level']);
    session_destroy();
    echo 'ko';
}
?>